class Routes {
    static getInstance() {
        if (!Routes.instance) {
            Routes.instance = new Routes();
        }
        return Routes.instance;
    }

    constructor() {
        this.login = {};
        this.userLogin = {};
        this.notLogin = {};
        this.validationData = {};
        this.errMap = {}; //用于错误提示
    }

    setNotLogin(routeName, validationData, func, err) {
        this.notLogin[routeName] = func;
        this.validationData[routeName] = validationData;
        if (err) {
            this.errMap[routeName] = err
        }
    }

    setLogin(routeName, validationData, func, err) {
        this.login[routeName] = func;
        this.validationData[routeName] = validationData;
        if (err) {
            this.errMap[routeName] = err
        }
    }

    setUserLogin(routeName, validationData, func, err) {
        this.userLogin[routeName] = func;
        this.validationData[routeName] = validationData;
        if (err) {
            this.errMap[routeName] = err
        }
    }
}

let routes = Routes.getInstance();
export default routes;